package com.naiterui.ehp.bs.agent.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bs.agent.entity.AsRecipelCount;

/**
 * 经纪人统计-处方相关统计
 *
 * @author yangfuya
 * @since 2022/2/16
 */
@Repository
public interface IAsRecipelCountRepository extends BaseJpaRepository<AsRecipelCount, Long> {
	@Query(value = "select sum(recipel_total) recipel_total, sum(order_price_total) order_price_total from as_recipel_count where agent_id=:agentId and generate_date=:generateDate group by agent_id", nativeQuery = true)
	List<Object[]> getTotalByAgentId(@Param("agentId") Long agentId, @Param("generateDate") String generateDate);

    @Query(value = "select *  from as_recipel_count where generate_date =:generateDate  limit 1",
        nativeQuery = true)
    AsRecipelCount getTotalByGenerateDate(@Param("generateDate") String generateDate);
}
